﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
 }
<div class="container-div">
    <div class="row">
        <div id="searchDiv" class="col-sm-12 search-collapse">
            <div class="select-list">
                <ul>

                </ul>
            </div>
        </div>
        <div class="btn-group-sm hidden-xs" id="toolbar">

        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="gridTable" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $("#mediaserverId").ysComboBox({
            url: '@Url.Content("~/CameraManage/CameraSessionManager/GetPushMediaList")',
            key: "mediaServerId",
            value: "mediaServerId",
            default: "vm_linux"
        });
        initGrid();

    });

    function btn_playUrl(id) {
        //播放地址
    }

    function btn_playList(id) {
        //播放者客户端列表
    }

    function initGrid() {
        var queryUrl = '@Url.Content("~/CameraManage/CameraSessionManager/CameraSessionList")';
        $('#gridTable').ysTable({
            url: queryUrl,
            columns: [
                { checkbox: false, visible: false },
                { field: 'mainId', title: '设备ID' },
                { field: 'mediaServerId', title: '流媒体服务' },
                { field: 'channelId', title: 'Channel ID' },
                { field: 'deviceId', title: 'Device ID' },
                { field: 'channelName', title: '设备名称' },
                { field: 'ipV4Address', title: 'IpV4' },
                { field: 'ipV6Address', title: 'IpV6' },
                {
                    field: 'deviceNetworkType', title: '网络类型', formatter: function (value, row, index) {
                        return top.getDataDictKey('DeviceNetworkType', value);
                    }
                },
                {
                    field: 'deviceStreamType', title: '流类型', formatter: function (value, row, index) {
                        return top.getDataDictValue('DeviceStreamType', value);
                    }
                },
                {
                    field: 'methodByGetStream', title: '拉流方式', formatter: function (value, row, index) {
                        return top.getDataDictValue('MethodByGetStream', value);
                    }
                },
                {
                    field: 'methodByGetStream', title: '拉流方式', formatter: function (value, row, index) {
                        return top.getDataDictValue('MethodByGetStream', value);
                    }
                },
                {
                    field: 'tlxy', title: '推流协议', formatter: function (value, row, index) {
                        if (!!row.mediaServerStreamInfo) {
                            return row.mediaServerStreamInfo.pushSocketType;
                        }
                    }
                },
                {
                    field: 'AutoVideo', title: '自动推拉流', formatter: function (value, row, index) {
                        if (value == true) {
                            return '<span class="badge badge-primary">' + "启用" + '</span>';
                        } else {
                            return '<span class="badge badge-error">' + "禁用" + '</span>';
                        }
                    }
                },
                {
                    field: 'AutoRecord', title: '自动录像', formatter: function (value, row, index) {
                        if (value == true) {
                            return '<span class="badge badge-primary">' + "启用" + '</span>';
                        } else {
                            return '<span class="badge badge-error">' + "禁用" + '</span>';
                        }
                    }
                },
                {
                    field: 'hasPtz', title: '云台控制', formatter: function (value, row, index) {
                        if (value == true) {
                            return '<span class="badge badge-primary">' + "启用" + '</span>';
                        } else {
                            return '<span class="badge badge-error">' + "禁用" + '</span>';
                        }
                    }
                },
                {
                    field: 'rtpWithTcp', title: 'TCP推流', formatter: function (value, row, index) {
                        if (value == true) {
                            return '<span class="badge badge-primary">' + "启用" + '</span>';
                        } else {
                            return '<span class="badge badge-error">' + "禁用" + '</span>';
                        }
                    }
                },
                {
                    field: 'defaultRtpPort', title: '默认端口', formatter: function (value, row, index) {
                        if (value == true) {
                            return '<span class="badge badge-primary">' + "启用" + '</span>';
                        } else {
                            return '<span class="badge badge-error">' + "禁用" + '</span>';
                        }
                    }
                },
                {
                    field: 'cz', title: '操作', formatter: function (value, row, index) {
                        if (!!row.mediaServerStreamInfo) {
                            var actions = [];
                            actions.push('<div style="display: flex;"><a class="btn btn-info btn-xs"  href="#" onclick="btn_playUrl(\'' + row.id + '\')">播放地址</a><a class="btn btn-info btn-xs" style="margin-left: 5px;" href="#" onclick="btn_playList(\'' + row.id + '\')">在线客户端</a></div>');
                            return actions.join('');
                        }
                    }
                },
            ],
            queryParams: function (params) {
                var pagination = $('#gridTable').ysTable('getPagination', params);
                var queryString = $('#searchDiv').getWebControls(pagination);
                return queryString;
            }
        });
    }

    function searchGrid() {
        $('#gridTable').ysTable('search');
        resetToolbarStatus();
    }


</script>
